package com.sskj.hhrt;


import android.content.Context;
import android.content.Intent;
import android.webkit.WebView;
import android.widget.LinearLayout;

import com.just.agentweb.AgentWeb;
import com.sskj.base.view.ToolBarLayout;

import butterknife.BindView;

/**
 * @author Hey
 * Create at  2019/03/27
 */
public class WebViewActivity extends MVPActivity<WebViewPresenter> {

    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.webView)
    WebView webView;
    AgentWeb mAgentWeb;
    private String url = "";

    @Override
    public int getLayoutId() {
        return R.layout.activity_web_view;
    }

    @Override
    public WebViewPresenter getPresenter() {
        return new WebViewPresenter();
    }

    @Override
    public void initView() {
        toolbar.setLeftButtonOnClickListener(v -> finish());
        url = getIntent().getStringExtra("url");
        mAgentWeb = AgentWeb.with(this)
                .setAgentWebParent(webView, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator()
                .createAgentWeb()
                .ready()
                .go(url);
//        mAgentWeb.getWebCreator().getWebView().loadData(url,"text/html","utf-8");
    }

    @Override
    public void initData() {

    }

    public static void start(Context context, String url) {
        Intent intent = new Intent(context, WebViewActivity.class);
        intent.putExtra("url", url);
        context.startActivity(intent);
    }

}
